<template>
	<view class="poster u-skeleton">
		<u-navbar title="邀请好友" :background="{'backgroundColor':'#fff'}" :borderBottom="false"
			class="u-skeleton-rect"></u-navbar>
		<view class="diy-swiper">
			<u-swiper :list="list.poster" :effect3d="true" effect3d-previous-margin='140' :autoplay='false'
				:imgHeight='800' :height='800' imgMode='heightFix' @change='change'></u-swiper>
		</view>
		<view class="code-box">
			<view class="code">
				<view class="left">
					<view class="tips">邀请码</view>
					<view class="code-txt">{{list.code}}</view>
				</view>
				<view class="right" @click="copy(list.code.toString())">复制</view>
			</view>
		</view>
		<view class="btn-box">
			<view class="btn" @click="btn">保存海报到手机</view>
		</view>
		<u-skeleton :loading="loding" :animation="true" bgColor="#FFF"></u-skeleton>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 首次进入加载
				loding: true,
				//轮播图数据
				list: [],
				//切换到那个图片
				current:0
			}
		},
		onShow() {
			this.getinfo();
		},
		methods: {
			getinfo() {
				this.$http.asyncSendrequest({
					url: '/profile/invitePoster',
					success: res => {
						if (res.code == '0') {
							this.list = res.data;
						}
						this.loding = false;
					}
				})
			},
			change(e){
				this.current = e;
			},
			// 复制数据
			copy(value) {
				this.$util.copy(value, (res) => {})
			},
			btn() {
				this.$util.getImglocal(this.list.poster[this.current])
			}
		}
	}
</script>

<style lang="scss" scoped>
	.poster {
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		min-height: 100vh;

		.diy-swiper {
			width: 100%;
			margin-top: 40rpx;
			height: 800rpx;
		}

		.code-box {
			width: 100%;
			padding: 0 30rpx;
			height: 150rpx;
			border-radius: 10rpx;
			margin-top: 60rpx;

			.code {
				width: 100%;
				height: 100%;
				background: #fff;
				border-radius: 10rpx;
				padding: 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.left {
					.tips {
						font-size: 26rpx;
						color: rgba(0, 0, 0, .2);
						margin-bottom: 20rpx;
					}

					.code-txt {
						font-size: 26rpx;
					}
				}

				.right {
					font-size: 28rpx;
					height: 50rpx;
					border-radius: 60rpx;
					width: 140rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					border: 1rpx solid rgba(0, 0, 0, .2);
				}
			}
		}

		.btn-box {
			margin-top: 50rpx;
			padding: 0 30rpx;
			width: 100%;

			.btn {
				width: 100%;
				height: 80rpx;
				color: #fff;
				background: #000000;
				border-radius: 6rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}

	}
</style>